/**
 * @author Fang Lu, fanglupku@gmail.com
 * 2011-3-25
 */
package code.extract;

import java.util.ResourceBundle;

public class CEConfig {
	private static final String PROPERTIES_FILE_NAME = "codeextract";
	private static ResourceBundle bundle;

	static {
		try {
			bundle = ResourceBundle.getBundle(PROPERTIES_FILE_NAME);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	private static String getValue(String key) {
		return bundle.getString(key).trim();
	}
	public static String getGoogleKeywordListFilename() {
		return getValue("google.keywordlist.filename");
	}
	public static String getGoogleKeywordCrawledListFilename() {
		return getValue("google.keywordcrawledlist.filename");
	}
	public static int getGoogleResultCount() {
		int count = 50;
		try{
			count = Integer.parseInt(getValue("google.result.count"));
		}catch (Exception e) {
			count = 50;
		}
		return count;
	}
	public static String getGoogleResultSavepath() {
		return getValue("google.result.savepath");
	}
	public static int getGoogleWaitSecondMax(){
		int max = 100;
		try{
			max = Integer.parseInt(getValue("google.waitsecond.max"));
			if (max < 0){
				max = 50;
			}
		}catch (Exception e) {
			max = 100;
		}
		return max;
	}
	public static int getGoogleWaitSecondMin(){
		int min = 50;
		try{
			min = Integer.parseInt(getValue("google.waitsecond.min"));
			if (min < 0){
				min = 50;
			}
		}catch (Exception e) {
			min = 50;
		}
		return min;
	}
	public static int getTrainingCrawlThreadNum(){
		int thread_num = 10;
		try{
			thread_num = Integer.parseInt(getValue("training.crawl.threadnum"));
			if (thread_num <= 0){
				thread_num = 10;
			}
		}catch (Exception e) {
			thread_num = 10;
		}
		return thread_num;
	}
	public static String getTrainingKeywordCrawledListFilename() {
		return getValue("training.keywordcrawledlist.filename");
	}
	public static String getTrainingLinkCrawledListFilename() {
		return getValue("training.linkcrawledlist.filename");
	}
	public static String getGoogleLinklistFilename() {
		return getValue("google.linklist.filename");
	}
	public static String getGoogleBDBDirname() {
		return getValue("google.bdb.dirname");
	}
	public static String getGoogleBDBDatabasename() {
		return getValue("google.bdb.databasename");
	}
	public static String getTrainingOriginalSavepath(){
		return getValue("training.original.savepath");
	}
	public static String getTrainingSegmentSavepath(){
		return getValue("training.segment.savepath");
	}
	public static String getAPIBDBDirname() {
		return getValue("api.bdb.dirname");
	}
	public static String getRefPageBDBDirname() {
		return getValue("ref.bdb.dirname");
	}
	public static String getRefPageBDBDatabasename() {
		return getValue("ref.bdb.databasename");
	}
	public static String getCodeExtractErrorFilename(){
		return getValue("code.extract.error.filename");
	}
	public static int getCodeExtractMaxseg(){
		int max = 5000;
		try{
			max = Integer.parseInt(getValue("code.extract.maxseg"));
			if (max <= 0){
				max = 5000;
			}
		}catch (Exception e) {
			max = 10;
		}
		return max;
	}
	public static int getCodeExtractMinseg(){
		int min = 1;
		try{
			min = Integer.parseInt(getValue("code.extract.minseg"));
			if (min <= 0){
				min = 5000;
			}
		}catch (Exception e) {
			min = 10;
		}
		return min;
	}
	public static int getBacklinkCrawlerThread(){
		int thread_num = 50;
		try{
			thread_num = Integer.parseInt(getValue("backlink.crawler.thread"));
			if (thread_num <= 0){
				thread_num = 50;
			}
		}catch (Exception e) {
			thread_num = 50;
		}
		return thread_num;
	}
}
